Sometimes some communication software needs these functions, such as receiving text messages, notifications, etc., asking the phone to make a ringtone, or vibrate, or glow to prompt the user to know.Often mobile phones have default settings, such as the user to turn on the ring + vibration, only the ring does not vibrate, completely mute and so on ...This is the time to have a rule, at least software settin
The source code is as follows:[Delphi]View PlainCopy
Uses
Androidapi. JNI. Os,
Androidapi.Jnibridge;
function Getvibratorarray (const Aintarr: array of Int64): tjavaarray
Var
Lindex:integer;
Begin
Result: = Tjavaarray
For LIndex: = Low (Aintarr) to High (Aintarr) does
Result.Items[lindex]: = Aintarr[lindex];
End
Procedure Vibratortest;
Var
Lvibratorobj:jobject;
Lvibrator:jvibrator;
ljavaarray:tjavaarray
Begin
{Vibrator Summary:
Cancel (): Off v
Vibrate, is called the Android API JNI inside the function, these are called Java, such as the following reference,UsesFMX. Helpers.android,ANDROIDAPI.JNI.APP,Androidapi.JNI.Os,Androidapi.jnibridge, Fmx.stdctrls;It's still a few steps,1 Create a new mobile projectOpen Xe6, file----new----Firemonkeymobile Application-delphi2 Select Black Application click OK.3 in the window that opens, put a few button controls.4. Click the Save button to save the prog
For some QML applications, vibration is a very important function. Especially for the game. So how do we vibrate in the QML application?We officially have an API Hapticseffect, the function of this API is to let our application to vibrate. Using this API is easy:Import QtQuick 2.0import ubuntu.components 1.1import qtfeedback 5.0/*! \brief MainView with a Label and Button Elements.*/mainview {//ObjectName fo
(ksystemsoundid_vibrate); Audioservicesdisposesystemsoundid (ksystemsoundid_vibrate);But I met a wonderful problem, is on the IOS10 test, other version I did not have a mobile phone test, the problem is that I found the call stop method, and did not immediately stop, the time of the stop is proportional to the time you play the vibration, the longer the vibration time, the call stopped, but also continue to vibrate for a period of time to stop, So I
Package cn.com. chenzheng_java;
Android. OS. vibrate represents the mobile phone vibrator. The usage is very simple. Get the example using the getsystemservice () method, and then call the vibrate method to implement vibration.
To use this vibrator, you must specify the permission in androidmanifest. xml
handled during the event, if the return value is false, then the hand touches the text area and starts shaking, shaking for five seconds. And if the return value is true, the moment the finger is released, in response to the condition in the else if, stop shaking. If you keep pressing it, it will stop for five seconds.Before you enable the vibration, you also need to register the Androidmanifest.xml in the vibration, otherwise it will be abnormal. The program hangs directly. The contents of the
Android alarm function, alarm bell sound, mobile phone starting to vibrate
To meet the company's project requirements, you must add the alarm function to the software,
Click the hand-drawn alarm icon to start shaking and send an alarm bell,
Layerlist, drawable, Vibrator, and soundpool are used.
Public class SosMainActivity extends BaseActivity {Private TextView sosTv1, sosTv2, sosTv3;Private int blueColor, whiteColor, transparent; Private Vibrato
Frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager. java public boolean javasmhapticfeedbacklw (WindowState win, int partition tid, boolean always ){....... case HapticFeedbackConstants. SAFE_MODE_DISABLED: return; // start in normal mode. If you do not want to vibrate, directly return; pattern = mSafeModeDisabledVibePattern; break; case HapticFeedbackConstants. SAFE_MODE_ENABLED: return; // start in safe mode. If you do no
protectedAudiomanager Audiomanager;protectedvibrator Vibrator; Audiomanager=(Audiomanager) Getsystemservice (Context.audio_service); //This method is called by the context vibrator=(Vibrator) Getsystemservice (Context.vibrator_service); //Ibid ./*** Vibrate and play tone*/ Public voidvibrateandplaytone (Emmessage message) {if(System.currenttimemillis ()-Lastnotifiytime ) { //received new messages within 2 seconds, skip play ringtone
1. Background does not executeLoad the library file first: audiotoolbox.frameworkIntroduction of header file: #import "audiotoolbox/audiotoolbox.h" (Warm tip: because it is called Objective-c Note the file name)Opening method: Audioservicesplaysystemsound (Ksystemsoundid_vibrate);You cannot modify the vibration parameters, each call generates a short 1-2-second vibration. On a platform that does not support vibration, the call does nothing, but it does not have an error-(void) Application: (UIAp
iOS play and vibrateuse Audioservicesplaysystemsound this interface for sound and vibration playback, of course, you need to add audiotoolbox.framework in the project1. Play VibrationAudioservicesplaysystemsound (ksystemsoundid_vibrate);2. Play a specific soundstatic Systemsoundid soundidtest = 0;NSString * Path = [[NSBundle mainbundle] pathforresource:@ "test" oftype:@ "wav"];if (path) {Audioservicescreatesystemsoundid (cfurlref) [Nsurl Fileurlwithpath:path], soundidtest);}Audioservicesplaysyst
Androidmanifest.xml Getting system permissionsVibration is realized by vibratorVibrator Mvibrator = (vibrator) mcontext.getsystemservice (Service.vibrator_service); //The previous parameter is the set vibration period array, the second parameter is the number of vibrations (-1 means shaking only once, 0 vibrations will continue)or directly set the vibration duration mvibrator.vibrate (5000);Long[] Pattern = {100};mvibrator.vibrate (pattern,-1);//Cancel Vibration mvibrator.cancel (); Let the vib
system will not enter sleep phenomenonRefer to the following method to have the dialog box appear above the lock screenThe OnCreate method is usedRequestwindowfeature (Window.feature_no_title); Hide TitleWindow win = GetWindow ();Windowmanager.layoutparams winparams = Win.getattributes ();Winparams.flags |= (WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON| WindowManager.LayoutParams.FL
The problem encountered in the project is that the sound is vibrating while the music is over and the vibration is over.First, you need to introduce #import Add a place where you need to play music:Audioservicesaddsystemsoundcompletion (ksystemsoundid_vibrate, NULL, NULL, systemaudiocallback, NULL);Audioservicesplaysystemsound (ksystemsoundid_vibrate);Explanation: Theksystemsoundid_vibrate provides the system with the vibration ID. Systemaudiocallback is the callback function, and the callback
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.